package com.hspedu.collection_;

import java.util.*;

public class CollectionE3 {
    @SuppressWarnings({"all"})
    public static void main(String[] args) {
        List col = new ArrayList();
        col.add(new Book("三国演绎",10.6));
        col.add(new Book("小李飞刀",5.6));
        col.add(new Book("红楼梦4",112222220.6));
        col.add(new Book("红楼梦",120.6));
        col.add(new Book("红楼梦2",1120.6));
        col.add(new Book("红楼梦2",1120.6));
        col.add(new Book("红楼梦2",1120.6));
        col.add(new Book("红楼梦2",1120.6));
        col.add(new Book("红楼梦2",1120.6));
        col.add(new Book("红楼梦2",1120.6));
        col.add(new Book("红楼梦2",1120.6));
        col.add(new Book("红楼梦2",1120.6));
        col.add(new Book("红楼梦2",1120.6));
        col.add(new Book("红楼梦3",11120.6));
        sort(col);
        ArrayList arrayList = new ArrayList();


    }
    public static void sort(List col){
        for (int i = 0; i < col.size() - 1; i++) {
            for (int j = 0; j < col.size() - 1 - i; j++) {
                Book book1 = (Book) col.get(j);
                Book book2 = (Book) col.get(j + 1);
                if(book1.getPrice() > book2.getPrice()){
                    Object temp = book1;
                    col.set(j,book2);
                    col.set(j + 1,temp);
                }
            }
        }
    }

}
